package com.ytzl.gotrip.controller;

import com.ytzl.gotrip.service.SendEmailService;
import com.ytzl.gotrip.utils.common.Dto;
import com.ytzl.gotrip.utils.common.DtoUtil;
import com.ytzl.gotrip.vo.userinfo.ItripUserVO;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api")
public class SendEmailController {
    @Resource
    private SendEmailService sendEmailService;
    @PostMapping("/doregister")
    public Dto sendEamil(@RequestBody ItripUserVO itripUserVo) throws Exception {
        sendEmailService.registerByEamil(itripUserVo);
        return DtoUtil.returnDataSuccess("成功");
    }

    @PutMapping("/activate")
    public Dto validateemail(@ApiParam(value = "登录邮箱")@RequestParam String user, @ApiParam(value = "短信验证码")@RequestParam String code) throws Exception {
        System.out.println("----------"+user+" " +code+"------------1");
        sendEmailService.validateEmail(user,code);
        return DtoUtil.returnDataSuccess("激活成功！！");
    }
}
